/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package app.utils;

import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

/**
 *
 * @author bharat
 */
public class SiftLogger {
    private static Logger logger ;
    
    static {
        logger = Logger.getLogger("SiftLogger");
        FileHandler fh = null;

        try {
            // This block configure the logger with handler and formatter
            fh = new FileHandler("SiftLog.txt", true);
            logger.addHandler(fh);
            logger.setLevel(Level.ALL);
            SimpleFormatter formatter = new SimpleFormatter();
            fh.setFormatter(formatter);

        }catch(Exception e){
            System.out.println("Error: Failed to create Logger.");
            e.printStackTrace();
        }
    }

    public static synchronized void log(Level lev, String logEntry){
        System.out.println("Log: " + logEntry);
        if (logger != null)
            logger.log(lev, logEntry);
    }
}
